<template>
	<view class="container">
		<view class="cu-list menu menu-list">
			<view class="cu-item arrow" v-if="item.isShow" v-for="(item,index) in menuList"
				:key="index" @click="menuClick(item)">
				<view class="content">
					<text class="item-title">{{item.name}}</text>
				</view>
			</view>
		</view>
		<view class="menu-out" @click="outLogin">
			<text>退出当前登录</text>
		</view>
	</view>
</template>

<script>
	let that;
	import personalApi from "@/api/personal.js"
	export default {
		data() {
			return {
				outShow: false,
				userInfo: '',
				menuList: [
					{
						name: '修改登录密码',
						url: '/pagesOrder/setPassword/setPassword?type=2',
						isShow: false
					},
					{
						name: '设置登录密码',
						url: '/pagesOrder/setPassword/setPassword?type=1',
						isShow: false
					},
					{
						name: '关于我们',
						url: '/pagesOrder/appletDeal/appletDeal?type=about_us&name=关于我们',
						isShow: true
					},
					{
						name: '用户协议',
						url: '/pagesOrder/appletDeal/appletDeal?type=user_agreement&name=用户协议',
						isShow: true
					},
					{
						name: '隐私协议',
						url: '/pagesOrder/appletDeal/appletDeal?type=privacy_agreement&name=隐私协议',
						isShow: true
					},
					{
						name: '会员协议',
						url: '/pagesOrder/appletDeal/appletDeal?type=vip_deal&name=会员协议',
						isShow: false
					}
				],
			}
		},
		onLoad() {
			this.userInfo = uni.getStorageSync('userInfo') || {}
			that = this;
			//是否有密码
			if (this.userInfo.password != '') {
				that.menuList[1].isShow = false;
			} else {
				that.menuList[0].isShow = false;
			}
		},
		methods: {
			//点击跳转
			menuClick(item) {
				this.$common.href(item.url);
			},
			//退出登录
			outLogin() {
				let _that = this
				uni.showModal({
					title: '温馨提示',
					confirmText: '确定',
					confirmColor: '#0177FD',
					cancelText: '再想想',
					cancelColor: '#666',
					content: '确定要退出吗？',
					success(res) {
						if(res.confirm) {
							_that.$store.state.userInfo = null
							_that.$store.state.zim.logout()
							_that.$store.state.zim.destroy()
							_that.$store.state.conversationList = []
							personalApi.loginOut().then(ots => {
								if(ots.code === 1) {
									_that.$common.msgShow(res.msg)
									_that.$common.outFun();
									
								}else {
									_that.$common.msgShow(res.msg)
								}
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "mySetting.scss";
</style>
